//
//  AssetTableViewController.m
//  project
//
//  Created by 李腾昊 on 2017/10/19.
//  Copyright © 2017年 Macmini. All rights reserved.
//

#import "AssetTableViewController.h"

#import "AssetHeaderView.h"
#import "AssetTableViewCell.h"

@interface AssetTableViewController ()

@property (nonatomic, retain)AssetHeaderView *assetHeaderView;

@end

@implementation AssetTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self setupNavBar];
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    self.tableView.tableHeaderView = self.assetHeaderView;
}

- (void)setupNavBar {
    self.navigationItem.title = @"我的资产";
    
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBtn setTitle:@"帮助" forState:UIControlStateNormal];
    [rightBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
    self.navigationItem.rightBarButtonItem = rightBarButtonItem;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    AssetTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"assetTableViewCell"];
    if (!cell) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"AssetTableViewCell" owner:self options:nil]lastObject];
        
    }
    
    return cell;
}

- (AssetHeaderView *)assetHeaderView {
    if(_assetHeaderView)
        return _assetHeaderView;
    
    _assetHeaderView = [[[ NSBundle mainBundle] loadNibNamed:@"AssetHeaderView" owner:nil options:nil]lastObject];
    _assetHeaderView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 305);
    
    return _assetHeaderView;
}

@end
